package enn;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;

/**
 * Created by Yu on 2017/11/6.
 */
@WebServlet("/stopServlet")
public class stopServlet extends HttpServlet {
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("UTF-8");         //返回页面防止出现中文乱码
            String url=request.getParameter("url");
            String pipelineid=request.getParameter("pipelineid");
            PrintWriter out=response.getWriter();
            if ("".equals(pipelineid)||null==pipelineid){
                out.write(400);
            }else {
                try {
                    String result=new MyHttpUtil().doPost(url+"rest/v1/pipeline/" + pipelineid + "/stop",new HashMap());
                    out.write(result);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

            out.close();
        }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}

